package com.login.springboot.runner;

import com.login.springboot.modbus.ModbusRTUOp;

public class ModbusDemo {
    public static void main(String[] args) throws Exception{
        ModbusRTUOp.init();
        //Modbus泛读泛烟感泛浓度实现:01 03 00 0B 00 01 F5 C8  响应0103020000B844

        //随机-80到80的数
        String old="";
        String str="";
        while(true){
            short[] data=ModbusRTUOp.batchReadHoldingRegisters(ModbusRTUOp.SLAVE_ADDRESS, 0x0B, 1);  //index从0开始，对应100
            str=data[0]+"";
            System.out.println(str);
            Thread.sleep(10);
            old=str;
        }
    }
}
